In [1]:
print("hello world")
In [2]:
x=7
In [3]:
x.bit_length()
Out[3]:
In [4]:
x=3.14159
In [5]:
type(x)
Out[5]:
In [6]:
x=0.25
In [7]:
x.as_integer_ratio()
Out[7]:
In [8]:
x="hello"
In [9]:
type(x)
Out[9]:
In [10]:
x.capitalize()
Out[10]:
In [11]:
x='world'
In [12]:
print(x)
In [13]:
x="""
Hello
World
"""
print(x)
In [14]:
x=(2,3,"text")
In [15]:
print(x)
In [16]:
x[2]
Out[16]:
In [17]:
x[-1]
Out[17]:
In [18]:
x[-2]
Out[18]:
In [19]:
x=[1,3,5,"hello"]
In [20]:
print(x)
In [21]:
x.append("world")
In [22]:
x
Out[22]:
In [23]:
x.pop()
Out[23]:
In [24]:
x
Out[24]:
In [25]:
x={"key":"value", "cat":"a small animal" }
In [26]:
x
Out[26]:
In [27]:
x['cat']
Out[27]:
In [28]:
x['dog']="a bigger animal"
In [29]:
x
Out[29]:
In [30]:
x.get('duck','not found')
Out[30]:
In [31]:
for i in [1,2,3]:
print(i)
In [32]:
for i in range(0,10,2):
print(i)
In [33]:
i=0
while i<5:
i+=1
print i
In [34]:
def f(x):
y=2*x
return y
In [35]:
f(3)
Out[35]:
In [36]:
g=f
In [37]:
g(5)
Out[37]:
In [38]:
x=[]
for i in range(1,13):
x.append(i*25)
In [39]:
x
Out[39]:
In [40]:
%%timeit -n1
x=[]
for i in range(1,13000000):
x.append(i*25)
In [41]:
x=[i*25 for i in range(1,13)]
In [42]:
x
Out[42]:
In [43]:
%%timeit -n1
x=[i*25 for i in xrange(1,13000000)]
In [44]:
x={i:i*25 for i in range(1,13)}
In [45]:
x
Out[45]:
In [46]:
with open("fibo_input.txt","r") as fp:
s=fp.read()
x=[int(i) for i in s.split()]
In [47]:
x
Out[47]:
In [ ]: